package imper.graphic.listener;

import imper.engine.entity.Country;
import imper.engine.entity.Industry;
import imper.engine.entity.IndustryType;
import imper.engine.util.ParameterManager;
import imper.graphic.view.IndustryView;

public class UpgradeIndustryListener implements Runnable
{
	protected IndustryType _industryType;

	protected IndustryView _view;

	public UpgradeIndustryListener(IndustryType pIndustryType, IndustryView pView)
	{
		this._industryType = pIndustryType;
		this._view = pView;
	}

	@Override
	public void run()
	{
		Country country = ParameterManager.getInstance().getMainCountry();
		Industry industry = country.getIndustry().get(_industryType.getId());
		if( industry != null)
		{
			industry.setSize(industry.getSize() + 2);					
		}
		else
		{
			Industry newIndustry = new Industry();
			newIndustry.setIndustryId(_industryType.getId());
			newIndustry.setSize(2);
			country.getIndustry().put(_industryType.getId(), newIndustry);
		}
		this._view.refreshView();

	}

}
